//
//  UIImage+Circle.m
//  FunnyVideo
//
//  Created by 李鑫 on 16/1/6.
//  Copyright © 2016年 NewEggTech. All rights reserved.
//

#import "UIImage+Circle.h"

@implementation UIImage (Circle)

- (UIImage *)circleImageBordWidth:(CGFloat)inset{
    UIGraphicsBeginImageContext(self.size);
    
    CGContextRef context =UIGraphicsGetCurrentContext();
    

    
    CGContextSetLineWidth(context,inset);
    
    CGContextSetStrokeColorWithColor(context, [UIColor blackColor].CGColor);
    
    CGRect rect = CGRectMake(5, 5, self.size.width - inset *2.0f, self.size.height - 5 *2.0f);
    
    CGContextAddEllipseInRect(context, rect);
    
    CGContextClip(context);
    
    
    [self drawInRect:rect];
    
    CGContextAddEllipseInRect(context, rect);
    
    CGContextStrokePath(context);
    
    //生成新的image
    
    UIImage *newimg = UIGraphicsGetImageFromCurrentImageContext();
    
    UIGraphicsEndImageContext();
    
    return newimg;
}

@end
